﻿using System;
using System.Web.UI;
using Business;

public partial class Controls_BackEnd_ExcuteDatabase : UserControl
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;
        btnSave.Visible = Session[SessionManager.SessionUserName].ToString().ToLower() == "thansau";
    }


    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AllCommand(object sender, EventArgs e)
    {
        switch (((Control)sender).ID)
        {
            case "btnSave":
                try
                {
                    if (string.IsNullOrEmpty(txtSQL.Text))
                    {
                        Config.Message(Page, Resources.Resource.SQLQueryIsNull, Resources.Resource.Warning);
                        return;
                    }
                    new Logs().ExcuteSql(txtSQL.Text);
                    Config.Message(Page, Resources.Resource.SaveSuccess, Resources.Resource.Messenger);
                }catch(Exception exception)
                {
                    Config.Message(Page,Resources.Resource.ErrorMsg,Resources.Resource.Warning);
                }
                break;

        }

    }
}
